package com.kye.express.business.common_tool_new.viewmodel;

import android.os.Parcel;

import com.kye.model.bean.common_tool.CommonToolItemBean;

/**
 * @author : Joe
 * @version : 1.0
 * @editor : Joe
 * @created : 10/01/2018
 * @updated : 10/01/2018
 * @description : <Description>
 * @update_reason : <UpdateReason>
 */

public class CommonToolNormalModel extends CommonToolItemBean {

    public CommonToolNormalModel(int id, String name, boolean isSelected, int position, int positionSelected, int positionUnselected) {
        super(id, name, isSelected, position, positionSelected, positionUnselected);
    }

    public static CommonToolNormalModel createFromCommonToolItemBean(CommonToolItemBean commonToolItemBean) {
        CommonToolNormalModel commonToolNormalModel = new CommonToolNormalModel();
        commonToolNormalModel.setIconRes(commonToolItemBean.getIconRes());
        commonToolNormalModel.setId(commonToolItemBean.getId());
        commonToolNormalModel.setName(commonToolItemBean.getName());
        commonToolNormalModel.setPosition(commonToolItemBean.getPosition());
        commonToolNormalModel.setPositionSelected(commonToolItemBean.getPositionSelected());
        commonToolNormalModel.setPositionUnselected(commonToolItemBean.getPositionUnselected());
        commonToolNormalModel.setSelected(commonToolItemBean.isSelected());
        commonToolNormalModel.setShowSelectedIcon(commonToolItemBean.isShowSelectedIcon());
        commonToolNormalModel.setTitle(commonToolItemBean.getTitle());
        return commonToolNormalModel;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        super.writeToParcel(dest, flags);
        dest.writeInt(this.id);
        dest.writeString(this.name);
        dest.writeByte(this.isSelected ? (byte) 1 : (byte) 0);
        dest.writeInt(this.position);
        dest.writeInt(this.positionSelected);
        dest.writeInt(this.positionUnselected);
        dest.writeByte(this.isShowSelectedIcon ? (byte) 1 : (byte) 0);
        dest.writeInt(this.iconRes);
        dest.writeString(this.title);
    }

    public CommonToolNormalModel() {
    }

    protected CommonToolNormalModel(Parcel in) {
        super(in);
        this.id = in.readInt();
        this.name = in.readString();
        this.isSelected = in.readByte() != 0;
        this.position = in.readInt();
        this.positionSelected = in.readInt();
        this.positionUnselected = in.readInt();
        this.isShowSelectedIcon = in.readByte() != 0;
        this.iconRes = in.readInt();
        this.title = in.readString();
    }

    public static final Creator<CommonToolNormalModel> CREATOR = new Creator<CommonToolNormalModel>() {
        @Override
        public CommonToolNormalModel createFromParcel(Parcel source) {
            return new CommonToolNormalModel(source);
        }

        @Override
        public CommonToolNormalModel[] newArray(int size) {
            return new CommonToolNormalModel[size];
        }
    };
}
